﻿<html>
  <head>
    <meta name="generator" content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
	<title>yyets test</title>
	<style>
		div {
			border: 1px solid gray;
		}
	</style>
    <script type="text/javascript" src="jquery-1.11.0.js"></script>	
	<script type="text/javascript" src="hashMap.js"></script>	
    <script type="text/javascript">
	var typesMap = new HashMap();
//$(document).ready(function(){
  $.ajax({
        url: "11057.xml",
        type: "GET",
        dataType: "xml",
        timeout: 1000,
        error: function(){
                alert("Error loading XML document");
        },
        success:function(xml){
			var $xml = $(xml);
			$xml.find('item').children().not('description').each(function(){
				$('body').append('<div>' + $(this).text() + '</div>');
			});
			
			$('body').append('<div id="desc" style="display:none">' +$xml.find('item > description').text()+ '</div>');
			setTimeout(loadType, 100);
			
        }
    });
//});
function loadType() {
	var desc = $('#desc').html();
	var tArray = desc.match(/\u3010[^\u3011]+\u3011/g);
	for (var i = 0; i < tArray.length; i++) {
		if (!typesMap.containsKey(tArray[i])) {
			var reg = new RegExp(tArray[i] + '[^\u3010]+<br>', 'g');
			var typeArray = [];
			var type = null;
			while ((type = reg.exec(desc))) {
				typeArray.push(type[0]);
			}
			typesMap.put(tArray[i], typeArray);
		}
	}
	for (var keySet = typesMap.keySet().sort().reverse(), i = 0; i < keySet.length; i++) {
		var content = typesMap.get(keySet[i]);
		for (var j = 0; j < content.length; j++) {
			content.match(/<br>[^:]:/);
		}
		$('body').append($('<div></div>').html('<span>' + keySet[i] + '片源(' + content.length + ')</span><div>'+
			content.join('')
			+'</div>'));
	}; 
}
</script>
  </head>
  <body></body>
</html>
